<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"wan-lei8.gitee.io","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="MVC三层架构">
<meta property="og:type" content="article">
<meta property="og:title" content="MVC三层架构加Manager层">
<meta property="og:url" content="https://wan-lei8.gitee.io/2020/10/12/MVC%E4%B8%89%E5%B1%82%E6%9E%B6%E6%9E%84%E5%8A%A0Manager%E5%B1%82/index.html">
<meta property="og:site_name" content="程序员西桐">
<meta property="og:description" content="MVC三层架构">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="c:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20211222112727310.png">
<meta property="og:image" content="c:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20211222112816376.png">
<meta property="og:image" content="c:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20211222113001904.png">
<meta property="og:image" content="c:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20211222113311929.png">
<meta property="article:published_time" content="2020-10-12T11:22:45.000Z">
<meta property="article:modified_time" content="2021-12-22T03:37:46.375Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="c:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20211222112727310.png">

<link rel="canonical" href="https://wan-lei8.gitee.io/2020/10/12/MVC%E4%B8%89%E5%B1%82%E6%9E%B6%E6%9E%84%E5%8A%A0Manager%E5%B1%82/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>MVC三层架构加Manager层 | 程序员西桐</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">程序员西桐</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">但行好事，莫问前程</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wan-lei8.gitee.io/2020/10/12/MVC%E4%B8%89%E5%B1%82%E6%9E%B6%E6%9E%84%E5%8A%A0Manager%E5%B1%82/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="程序员西桐">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          MVC三层架构加Manager层
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-10-12 19:22:45" itemprop="dateCreated datePublished" datetime="2020-10-12T19:22:45+08:00">2020-10-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-12-22 11:37:46" itemprop="dateModified" datetime="2021-12-22T11:37:46+08:00">2021-12-22</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h3 id="MVC三层架构"><a href="#MVC三层架构" class="headerlink" title="MVC三层架构"></a>MVC三层架构</h3><span id="more"></span>

<p>我们在刚刚成为程序员的时候，就会被前辈们 “教育” 说系统的设计要遵循 <strong>MVC（Model-View-Controller）</strong>架构。它将整体的系统分成了 Model（模型），View（视图）和 Controller（控制器）三个层次，也就是将用户视图和业务处理隔离开，并且通过控制器连接起来，很好地实现了表现和逻辑的解耦，是一种标准的软件分层架构。</p>
<img src="C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211222112727310.png" alt="image-20211222112727310" style="zoom: 67%;" />

<p>MVC分层架构是架构上最简单的一种分层方式。为了遵循这种分层架构我们在构建项目时往往会建立这样三个目录：controller、service 和 dao，它们分别对应了表现层、逻辑层还有数据访问层。</p>
<p><img src="C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211222112816376.png" alt="image-20211222112816376"></p>
<p>每层的作用如下：</p>
<ul>
<li>Controller层：主要是对访问控制进行转发，各类基本参数校验，或者不复用的业务简单处理。</li>
<li>Service层：主要是处理业务逻辑和事务</li>
<li>Dao层：负责与底层数据库MySQL，Oracle等进行数据交互</li>
</ul>
<p>可是随着我们的业务逻辑越来复杂，代码写的越来越多，这种简单的三层架构的问题也越来越明显。</p>
<h2 id="MVC架构弊端"><a href="#MVC架构弊端" class="headerlink" title="MVC架构弊端"></a>MVC架构弊端</h2><p>传统的MVC分层有以下几个很明显的问题：</p>
<ol>
<li>Service层代码臃肿</li>
<li>Service层很容易出现大事务，事务嵌套，导致问题很多，而且极难排查</li>
<li>dao层参杂业务逻辑</li>
<li>dao层sql语句复杂，关联查询比较多</li>
</ol>
<p>为了解决这个问题，我们参考《alibaba java开发手册》，在Service层之下再独立出一个通用业务处理层（Manager层）</p>
<img src="C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211222113001904.png" alt="image-20211222113001904" style="zoom:67%;" />

<p>在这个分层架构中主要增加了 Manager 层，它与 Service 层的关系是：Manager 层提供原子的服务接口，Service 层负责依据业务逻辑来编排原子接口。</p>
<h2 id="Manager层的特征"><a href="#Manager层的特征" class="headerlink" title="Manager层的特征"></a>Manager层的特征</h2><p>在《alibaba java开发手册》中是这样描述Manager层的：</p>
<blockquote>
<p>Manager 层：通用业务处理层，它有如下特征：</p>
<ol>
<li>对第三方平台封装的层，预处理返回结果及转化异常信息，适配上层接口；</li>
<li>对 Service 层通用能力的下沉，如缓存方案、中间件通用处理；</li>
<li>与 DAO 层交互，对多个 DAO 的组合复用。</li>
</ol>
</blockquote>
<p>在实际开发中我们可以这样使用Manager层</p>
<ol>
<li>杂业务，service提供数据给Manager层，负责业务编排，然后把事务下沉到Manager层，Manager层不允许相互调用，不会出现事务嵌套。</li>
<li>专注于不带业务sql语言，也可以在manager层进行通用业务的dao层封装。</li>
<li>避免复杂的join查询，数据库压力比java大很多，所以要严格控制好sql，所以可以在manager层进行拆分，比如复杂查询。</li>
</ol>
<p><strong>当然对于简单的业务，可以不使用Manager层。</strong></p>
<h2 id="Manager层使用案例"><a href="#Manager层使用案例" class="headerlink" title="Manager层使用案例"></a>Manager层使用案例</h2><p>这里我们举个例子说明一下Manager层的使用场景：</p>
<p>假设你有一个用户系统，他有一个获取用户信息的接口，它调用逻辑Service层的 <code>getUser</code> 方法，<code>getUser</code>方法又和 <code>User DB</code> 交互获取数据。如下图左边展示部分。</p>
<p>这时，产品提出一个需求，在 APP 中展示用户信息的时候，如果用户不存在，那么要自动给用户创建一个用户。同时，要做一个 HTML5 的页面，HTML5 页面要保留之前的逻辑，也就是不需要创建用户。</p>
<img src="C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20211222113311929.png" alt="image-20211222113311929" style="zoom:80%;" />

<p>此时按照传统的三层架构，逻辑层的边界就变得不清晰，表现层也承担了一部分的业务逻辑，因为我们往往会在表现层Controller中增加业务逻辑处理，将获取用户和创建用户接口编排起来。</p>
<p>而添加Manager层以后，Manager 层提供创建用户和获取用户信息的接口，而 Service 层负责将这两个接口组装起来。这样就把原先散布在表现层的业务逻辑都统一到了 Service 层，每一层的边界就非常清晰了。</p>
<p>接下来我们看一段实际代码说明一下Service层与Manager层如何进行区分？</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Transactional(rollbackFor = Throwable.class)</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> Result&lt;String&gt; <span class="title">upOrDown</span><span class="params">(Long departmentId, Long swapId)</span> </span>&#123;</span><br><span class="line">  <span class="comment">// 验证 1</span></span><br><span class="line">  DepartmentEntity departmentEntity = departmentDao.selectById(departmentId);</span><br><span class="line">  <span class="keyword">if</span> (departmentEntity == <span class="keyword">null</span>) &#123;</span><br><span class="line">    <span class="keyword">return</span> Result.error(<span class="string">&quot;部门xxx不存在&quot;</span>);</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="comment">// 验证 2</span></span><br><span class="line">  DepartmentEntity swapEntity = departmentDao.selectById(swapId);</span><br><span class="line">  <span class="keyword">if</span> (swapEntity == <span class="keyword">null</span>) &#123;</span><br><span class="line">    <span class="keyword">return</span> Result.error(<span class="string">&quot;部门xxx不存在&quot;</span>);</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="comment">// 验证 3</span></span><br><span class="line">  Long count = employeeDao.countByDepartmentId(departmentId);</span><br><span class="line">  <span class="keyword">if</span> (count != <span class="keyword">null</span> &amp;&amp; count &gt; <span class="number">0</span>) &#123;</span><br><span class="line">    <span class="keyword">return</span> Result.error(<span class="string">&quot;员工不存在&quot;</span>);</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="comment">// 操作数据库 4</span></span><br><span class="line">  Long departmentSort = departmentEntity.getSort();</span><br><span class="line">  departmentEntity.setSort(swapEntity.getSort());</span><br><span class="line">  departmentDao.updateById(departmentEntity);</span><br><span class="line">  swapEntity.setSort(departmentSort);</span><br><span class="line">  departmentDao.updateById(swapEntity);</span><br><span class="line">  <span class="keyword">return</span> Result.OK(<span class="string">&quot;success&quot;</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>上面代码在我们在我们采用三层架构时经常会遇到，<strong>那么它有什么问题呢？</strong></p>
<p>上面的代码是典型的长事务问题（<em>类似的还有调用第三方接口</em>），前三步都是使用 connection 进行验证操作，但是由于方法上有@Transactional 注解，所以这三个验证都是使用的同一个 connection。</p>
<p>若对于复杂业务、复杂的验证逻辑，会导致整个验证过程始终占用该 connection 连接，占用时间可能会很长，直至方法结束，connection 才会交还给数据库连接池。</p>
<p>对于复杂业务的不可预计的情况，长时间占用同一个 connection 连接不是好的事情，应该尽量缩短占用时间。</p>
<blockquote>
<p><em>说明：对于@Transactional 注解，当 spring 遇到该注解时，会自动从数据库连接池中获取 connection，并开启事务然后绑定到 ThreadLocal 上，如果业务并没有进入到最终的 操作数据库环节，那么就没有必要获取连接并开启事务，应该直接将 connection 返回给数据库连接池，供其他使用。</em></p>
</blockquote>
<p>所以我们在加入Manager层以后可以这样写：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">DepartmentService.<span class="function">java</span></span><br><span class="line"><span class="function">  </span></span><br><span class="line"><span class="function"><span class="keyword">public</span> Result&lt;String&gt; <span class="title">upOrDown</span><span class="params">(Long departmentId, Long swapId)</span> </span>&#123;</span><br><span class="line">  <span class="comment">// 验证 1</span></span><br><span class="line">  DepartmentEntity departmentEntity = departmentDao.selectById(departmentId);</span><br><span class="line">  <span class="keyword">if</span> (departmentEntity == <span class="keyword">null</span>) &#123;</span><br><span class="line">    <span class="keyword">return</span> Result.error(<span class="string">&quot;部门xxx不存在&quot;</span>);</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="comment">// 验证 2</span></span><br><span class="line">  DepartmentEntity swapEntity = departmentDao.selectById(swapId);</span><br><span class="line">  <span class="keyword">if</span> (swapEntity == <span class="keyword">null</span>) &#123;</span><br><span class="line">    <span class="keyword">return</span> Result.error(<span class="string">&quot;部门xxx不存在&quot;</span>);</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="comment">// 验证 3</span></span><br><span class="line">  Long count = employeeDao.countByDepartmentId(departmentId);</span><br><span class="line">  <span class="keyword">if</span> (count != <span class="keyword">null</span> &amp;&amp; count &gt; <span class="number">0</span>) &#123;</span><br><span class="line">    <span class="keyword">return</span> Result.error(<span class="string">&quot;员工不存在&quot;</span>);</span><br><span class="line">  &#125;</span><br><span class="line">  </span><br><span class="line">  <span class="comment">// 操作数据库 4</span></span><br><span class="line">  departmentManager.upOrDown(departmentSort,swapEntity);</span><br><span class="line"></span><br><span class="line">  <span class="keyword">return</span> Result.OK(<span class="string">&quot;success&quot;</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">DepartmentManager.java</span><br><span class="line">  </span><br><span class="line"><span class="meta">@Transactional(rollbackFor = Throwable.class)</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">upOrDown</span><span class="params">(DepartmentEntity departmentEntity ,DepartmentEntity swapEntity)</span></span>&#123;</span><br><span class="line">  Long departmentSort = departmentEntity.getSort();</span><br><span class="line">  departmentEntity.setSort(swapEntity.getSort());</span><br><span class="line">  departmentDao.updateById(departmentEntity);</span><br><span class="line">  swapEntity.setSort(departmentSort);</span><br><span class="line">  departmentDao.updateById(swapEntity);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>将数据在 service 层准备好，然后传递给 manager 层，由 manager 层添加<code>@Transactional</code>事务注解进行数据库操作。</p>

    </div>
<div>
  
    <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>

  
</div>

    
    
    
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://wan-lei8.gitee.io/2020/10/12/MVC%E4%B8%89%E5%B1%82%E6%9E%B6%E6%9E%84%E5%8A%A0Manager%E5%B1%82/" title="MVC三层架构加Manager层">https://wan-lei8.gitee.io/2020/10/12/MVC三层架构加Manager层/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/09/05/SpringBoot%E5%BC%82%E6%AD%A5%E7%BC%96%E6%8E%92/" rel="prev" title="SpringBoot异步编排">
      <i class="fa fa-chevron-left"></i> SpringBoot异步编排
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/11/26/List%E5%8E%BB%E9%87%8D/" rel="next" title="List去重">
      List去重 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#MVC%E4%B8%89%E5%B1%82%E6%9E%B6%E6%9E%84"><span class="nav-number">1.</span> <span class="nav-text">MVC三层架构</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#MVC%E6%9E%B6%E6%9E%84%E5%BC%8A%E7%AB%AF"><span class="nav-number"></span> <span class="nav-text">MVC架构弊端</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Manager%E5%B1%82%E7%9A%84%E7%89%B9%E5%BE%81"><span class="nav-number"></span> <span class="nav-text">Manager层的特征</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Manager%E5%B1%82%E4%BD%BF%E7%94%A8%E6%A1%88%E4%BE%8B"><span class="nav-number"></span> <span class="nav-text">Manager层使用案例</span></a></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt=""
      src="/images/avatar.png">
  <p class="site-author-name" itemprop="name"></p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives">
          <span class="site-state-item-count">41</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/yourname" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;yourname" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="/malegod958@163.com" title="E-Mail → malegod958@163.com"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>
  <div class="cc-license motion-element" itemprop="license">
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" class="cc-opacity" rel="noopener" target="_blank"><img src="/images/cc-by-nc-sa.svg" alt="Creative Commons"></a>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 2018 – 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">万磊</span>
</div>
  <div class="powered-by">

  </div>

        








      </div>
    </footer>
  </div>

  
  
  <script color='' opacity='0.5' zIndex='-1' count='99' src="/lib/canvas-nest/canvas-nest.min.js"></script>
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

  
	<script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>
	

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/src/clicklove.js"></script>
